package com.zyf.audio;

import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;

/**
 * Created by hp on 2021/10/15.
 */
public class SendThread extends Thread {
    private Socket socket;
    public SendThread(Socket socket){
        this.socket = socket;
    }
    public void run(){
        InputStream is = null;
        byte[] by = new byte[1024];
        try {
            while(true){
                is = socket.getInputStream();
                if (is.read(by)!=-1){
                    System.out.println(this.getName()+"说:"+new String(by));
                }
                //Thread.sleep(10000);
            }
        }catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (is!=null) is.close();
                if (this.socket!=null) this.socket.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
